package com.yingpai.fitness.dvp_2_0.main.adapter.shop;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.ArrayList;


public class CustomPagerAdapter extends FragmentPagerAdapter {

    private ArrayList<Fragment> mFragmentList;//Fragment集合

    private String[] mTitlesBottomTab;//标题 文本

    public CustomPagerAdapter(FragmentManager fm, ArrayList<Fragment> mFragmentList, String[] mTitlesBottomTab) {
        super(fm);
        this.mFragmentList = mFragmentList;
        this.mTitlesBottomTab = mTitlesBottomTab;
    }


    @Override
    public Fragment getItem(int position) {
        return mFragmentList != null ? mFragmentList.get(position) : null;
    }

    @Override
    public int getCount() {
        return mFragmentList != null ? mFragmentList.size() : 0;
    }

    /**
     * 文本
     *
     * @param position
     * @return
     */
    @Override
    public CharSequence getPageTitle(int position) {
        return mTitlesBottomTab != null ? mTitlesBottomTab[position] : "";
    }
}
